﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Jogo_Grupo2.Elementos
{
    class Inimigo:Objeto2D
    {
        float timer = 0;
        float intervalo = 180f;
        int curframe = 0;
        int spritewidth;
        int spriteheight;
        Rectangle spriteRect;
        int ataque;
        SpriteEffects invertido = SpriteEffects.FlipHorizontally;
        

        Random random = new Random();

        enum InimigoState
            {
              andando,atacando,
            }

        InimigoState statuszumbi = InimigoState.andando;

        public Inimigo(Texture2D textura, Vector2 posicao, SpriteEffects spriteEffects)
            : base(textura, posicao)
        {

            this.invertido = spriteEffects;
            this.texture = textura;
            this.position = posicao;
            spritewidth = textura.Width / 6;
            spriteheight = textura.Height ;
            spriteRect = new Rectangle(curframe * spritewidth, curframe * spriteheight, spritewidth, spriteheight);
            

        }

        public override Rectangle collisionBox()
        {
            return new Rectangle((int)position.X, (int)position.Y, spritewidth, spriteheight);
        }

        public float AtaqueInimigo()
        {
            
                return 0.01f;
            
        }

        
        public override void Update(GameTime gameTime)
        {
            //if(Game1.instancia.Content.Load<Texture2D>("zumbi2")){
            timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (curframe >= 5)
                curframe = 0;
            if (timer >= intervalo)
            {
                timer = 0;
                curframe++;
            }
            spriteRect.X = curframe * spritewidth;

          
            if(invertido == SpriteEffects.None)
                this.position.X -= 1;

            else
                this.position.X += 1;
          
             

            //}
            
            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, new Rectangle((int)position.X, (int)position.Y, spritewidth, spriteheight), spriteRect, Color.White,0,Vector2.Zero,invertido,0);
        }



    }
}
